<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./js/layui/layui.all.js"></script>
    <script src="/js/common.js"></script>
</head>
<body>
   <form action="/admin/login" method="post" id="form">
       用户名:<input type="text" id="username"/> <br>
       密码:<input type="password" id="password"/> <br>
       <button type="button" id="btnLogin">登录</button>
   </form>
</body>
</html>

<script>
    var $ = layui.$;

    $("#btnLogin").click(function(){
        var username = $("#username").val();
        var password = $("#password").val();
        $.ajax({
            url:'/admin/login',
            method:'post',
            data:{username:username,password:password},
            success:function(res)
            {
                if (res=="success")
                {
                    location='main.html';
                    //var token = layui.data('local_store').token;
                    //alert(token)
                }
                else
                {
                    layer.msg("用户名或密码错误");
                }
            }
        });
    });
</script>